<!DOCTYPE html>
<html th:lang="${language}" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
  <th:block th:include="include :: header('用户列表')" />

</head>
<body>
<div class="col-sm-12 select-table table-striped">
    <table id="bootstrap-table"></table>
</div>


<th:block th:include="include :: footer" />
<script th:inline="javascript">
  var prefix = "/okrAlign"
  // var list = [[${list}]]
  var source = [[${source}]]
  queryUserList()

  function queryUserList(){
    $(function (){
              var options = {
                url : prefix + "/ObjList",
                viewUrl: ctx + "okr/info/view/{id}",
                columns : [
                  {
                    field: 'id',
                    visible: false
                  },
                  {
                    field: 'userId',
                    visible: false,
                    sortable: true

                  },
                  {
                    field: 'deptId',
                    visible: false
                  },
                  {
                    field: 'userName',
                    title: '用户名',

                  },
                  {
                    field: 'content',
                    title: 'Objective'
                  },
                  {
                    title: '对齐',
                    align: 'center',
                    formatter: function(value, row, index){
                      var actions = []
                      actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="addAlign(\'' + row.id + '\')"><i class="fa fa-edit"></i>[[#{okr.align}]]</a>')
                      return actions.join('')
                    }
                  }
                ]
              }
              $.table.init(options)
            }
    )
  }


  function addAlign(okrId){
    $.ajax({
      url: prefix + "/addAlign",
      type:'POST',
      data: { "parentId" : okrId, "okrId" : source},
      success: function(data){
        if(data.code === 500){
          $.modal.msg(data.msg, modal_status.FAIL)
        }else{
          $.modal.msgReload(data.msg, modal_status.SUCCESS)
        }
      }
    })
  }
</script>
</body>
</html>